Skip to content

feat(cli): emit telemetry for the validate action - #1864

Open
iankhou wants to merge 6 commits into
mainfrom
telemetry-validate-event
Open

feat(cli): emit telemetry for the validate action#1864
iankhou wants to merge 6 commits into
mainfrom
telemetry-validate-event

Conversation

@iankhou

@iankhou iankhou commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Description

The cdk validate action (unstable) runs offline and online validation but currently emits no telemetry. This adds a VALIDATE telemetry event so we can measure, at minimum, that the validation engine ran (start time, duration, success/failure), and whether offline validation caught errors that would have failed a deployment.

Not included

cdk validate --watch does not emit VALIDATE events.

We have, separately, enabled our Telemetry backend to accept VALIDATE events.

Checklist

  • Unit tests added/updated (count-validation-results.test.ts, cli-io-host.test.ts, validate.test.ts + io-snapshots)
  • Integration tests: n/a — no new resource types or cross-service interactions
  • No manual edits to generated files

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

Adds a VALIDATE telemetry event covering the validation phase of cdk validate (offline report collection and online CloudFormation validation, excluding synthesis), with counters for offline violations per severity, offlineWouldFailDeploy (offline validation found a report that would have failed cdk deploy), and onlineViolations.
@github-actions

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@aws-cdk-automation
aws-cdk-automation requested a review from a team August 20, 2026 14:27
@iankhou
iankhou deployed to no-approval August 20, 2026 14:27 — with GitHub Actions Active
@iankhou iankhou changed the title feat(cli): DO NOT MERGE emit telemetry for the validate action feat(cli): emit telemetry for the validate action Aug 24, 2026
- Remove the pre-synthesis before the VALIDATE span: it made the
  user-visible 'Synthesis time' message report the cache hit (~0s)
  instead of the real duration, and it moved app-crash-during-synth
  outside the span. Synthesis now runs inside the VALIDATE span; the
  SYNTH event (instrumented in CloudExecutable) stays accurate.
- Extract wouldFailDeploy() from throwIfValidationFailures and use it
  for the offlineWouldFailDeploy counter, instead of re-deriving only
  the default failAt branch.
- Only set ValidateResult.onlineReports when online validation ran, so
  undefined distinguishes 'skipped' from 'ran clean' as documented.
- Deduplicate sum() into util/arrays instead of a third private copy.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated 1 comment.

Comment thread packages/aws-cdk/lib/cli/cdk-toolkit.ts
Uses the validate-app fixture (SecurityPlugin + construct annotation) to
assert the VALIDATE event and all four counter kinds in the telemetry
file, and asserts the batch POST succeeds against the real endpoint,
which doubles as an end-to-end check that the telemetry backend accepts
the VALIDATE event type.
…nter key

Newer aws-cdk-lib normalizes the fixture plugin's non-standard
'cost-optimization' severity to 'custom', so assert the stable counter
keys plus the total offline violation count instead of that key.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants